<!DOCTYPE html>
<html>
<head>
    <head th:include="header :: header"></head>
    <link type="text/css" rel="stylesheet" th:href="@{/statics/css/normalize.css}">
    <link type="text/css" rel="stylesheet" th:href="@{/statics/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/statics/css/AdminLTE.min.css}">
    <link rel="stylesheet" th:href="@{/statics/css/all-skins.min.css}">

    <style th:utext="${loginStyle}">
    </style>

    <style>
        #rrapp{
            margin-top: unset;
        }
    </style>
</head>
<body class="bg-dark" th:style="${systemBg}">
<div class="login-logo" style="margin-top: 12vh">
    <h1 th:utext="'<img height=\'100\' src=\'favicon.ico\'/>'+${systemName}"></h1>
</div>
<div class="login-box" id="rrapp" v-cloak>

  <!-- /.login-logo -->
  <div class="login-box-body login-form">
      <p class="login-box-msg">管理员登录</p>
      <div v-if="error" class="alert alert-danger alert-dismissible">
        <h5 style="margin: 0px;"><i class="fa fa-exclamation-triangle"></i> {{errorMsg}}</h5>
      </div>
      <div class="form-group has-feedback">
        <input type="text" class="form-control" v-model="username" placeholder="账号">
        <span class="glyphicon glyphicon-user form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input type="password" class="form-control" v-model="password" placeholder="密码">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <!--<div class="form-group has-feedback">-->
        <!--<input type="text" class="form-control" v-model="captcha" @keyup.enter="login" placeholder="验证码">-->
        <!--<span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>-->
      <!--</div>-->
      <!--<div class="form-group has-feedback">-->
        <!--<img alt="如果看不清楚，请单击图片刷新！" class="pointer" :src="src" @click="refreshCode">-->
        <!--&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" @click="refreshCode">点击刷新</a>-->
      <!--</div>-->
      
      
      <div class="row">
        <div class="col-xs-8">
          <div class="checkbox icheck">
          </div>
        </div>
        <!-- /.col -->
        <div class="col-xs-4">
          <button type="button" class="btn btn-primary btn-block btn-flat" @click="login">登录</button>
        </div>
        <!-- /.col -->
      </div>
    <!-- /.social-auth-links -->

  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<script th:src="@{/statics/libs/jquery.min.js}"></script>
<script th:src="@{/statics/libs/vue.min.js}"></script>
<script th:src="@{/statics/libs/bootstrap.min.js}"></script>
<script th:src="@{/statics/libs/jquery.slimscroll.min.js}"></script>
<script th:src="@{/statics/libs/fastclick.min.js}"></script>
<script th:src="@{/statics/libs/app.js}"></script>
<script type="text/javascript">
var vm = new Vue({
	el:'#rrapp',
	data:{
		username: '',
		password: '',
		captcha: '',
		error: false,
		errorMsg: '',
		src: 'captcha.jpg'
	},
	beforeCreate: function(){
		if(self != top){
			top.location.href = self.location.href;
		}
	},
	methods: {
		refreshCode: function(){
			// this.src = "captcha.jpg?t=" + $.now();
		},
		login: function (event) {
			// var data = "username="+vm.username+"&password="+vm.password+"&captcha="+vm.captcha;
			var data = "username="+vm.username+"&password="+vm.password;
			$.ajax({
				type: "POST",
			    url: "sys/login",
			    data: data,
			    dataType: "json",
			    success: function(result){
					if(result.code == 0){//登录成功
                        location.href ='index.html';
					}else{
						vm.error = true;
						vm.errorMsg = result.msg.substring(0, result.msg.indexOf(","));
						
						vm.refreshCode();
					}
				}
			});
		}
	}
});
</script>
</body>
</html>
